package com.demo.restResult;

/**
 * 自定义快速响应信息
 */
public class ResultGenerator {
    //只返成功信息
    public static RestResult genSuccessResult() {
        return new RestResult(ResultCode.SUCCESS);
    }

    //信息+数据
    public static <T> RestResult<T> genSuccessResult(T data) {
        return new RestResult(200, "SUCCESS", data);
    }

    //返回自定义消息
    public static RestResult genFailResult(String message) {
        return new RestResult(ResultCode.FAIL.getCode(), message);
    }

    /**
     * 未验证error 构造器
     * @return
     */
    public static RestResult genUnauthResult() {
        return new RestResult(ResultCode.UNAUTHORIZED);
    }
}
